package com.example.myblog01.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        加入LoginInterceptor的判断
        registry.addInterceptor(new LoginInterceptor())
//                拦截/admin/**
                .addPathPatterns("/admin/**")
//                .addPathPatterns("/")
//                排除/admin
                .excludePathPatterns("/admin")
                .excludePathPatterns("/admin/login");

    }
}
